package com.trade.okxserver.enums;

import java.sql.Time;

public enum TimeRange {

    // 1s/1m/3m/5m/15m/30m/1H/2H/4H/ 6H/12H/1D/2D/3D/1W/1M/3M /6Hutc/12Hutc/1Dutc/2Dutc/3Dutc/1Wutc/1Mutc/3Mutc
    S1(1000, "1s"),
    S5(5000, "5s"),
    S10(10000, "10s"),
    S15(15000, "15s"),
    M1(60000, "1m"),
    M3(180000, "3m"),
    M5(300000, "5m"),
    M15(900000, "15m"),
    M30(1800000, "30m"),
    H1(3600000, "1H"),
    H2(7200000, "2H"),
    H4(14400000, "4H"),
    H6(21600000, "6H"),
    H12(43200000, "12H"),
    D1(86400000, "1D"),
    D2(172800000, "2D"),
    D3(259200000, "3D"),
    W1(604800000, "1W"),
    MO1(2592000000L, "1M"),
    MO3(7776000000L, "3M"),
    H6UTC(21600000, "6Hutc"),
    H12UTC(43200000, "12Hutc"),
    D1UTC(86400000, "1Dutc"),
    D2UTC(172800000, "2Dutc"),
    D3UTC(259200000, "3Dutc"),
    W1UTC(604800000, "1Wutc"),
    M1UTC(2592000000L, "1Mutc"),
    M3UTC(7776000000L, "3Mutc");

    private final long milliseconds;
    private final String label;

    TimeRange(long milliseconds, String label) {
        this.milliseconds = milliseconds;
        this.label = label;
    }

    public static TimeRange getByMilliSecond(Long milliseconds){
        for (TimeRange value : TimeRange.values()) {
            if(value.milliseconds == milliseconds){
                return value;
            }
        }
        return null;
    }

    public long getMilliseconds() {
        return milliseconds;
    }

    public String getLabel() {
        return label;
    }


}
